home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / OpenGL 1.0 SDK / Source / Libraries / glut / glut_bwidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-18  |  1.1 KB  |  45 lines  |  [TEXT/CWIE]

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include "glut.h"
  9. #include "glutint.h"
  10. #include "glutbitmap.h"
  11.  
  12. int glutBitmapLength(GLUTbitmapFont font, const unsigned char *string);
  13.  
  14. int glutBitmapWidth(GLUTbitmapFont font, int c)
  15. {
  16.   BitmapFontPtr fontinfo = (BitmapFontPtr) font;
  17.   BitmapCharPtr ch;
  18.  
  19.   if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars)
  20.     return 0;
  21.   ch = fontinfo->ch[c - fontinfo->first];
  22.   if (ch)
  23.     return ch->advance;
  24.   else
  25.     return 0;
  26. }
  27.  
  28. int glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
  29. {
  30.   int c, length;
  31.   BitmapFontPtr fontinfo = (BitmapFontPtr) font;
  32.   BitmapCharPtr ch;
  33.  
  34.   length = 0;
  35.   for (; *string != '\0'; string++) {
  36.     c = *string;
  37.     if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars) {
  38.       ch = fontinfo->ch[c - fontinfo->first];
  39.       if (ch)
  40.     length += ch->advance;
  41.     }
  42.   }
  43.   return length;
  44. }
  45.